<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('进货订单列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <p>入库单编号：</p>
                            <input type="text" name="purStoId"/>
                        </li>
                        <li>
                            <p>总金额：</p>
                            <input type="text" name="purMoney"/>
                        </li>
                        <li class="select-time">
                            <p>时间：</p>
                            <input type="text" class="time-input" id="startTime" placeholder="时间"
                                   name="params[beginPurSubmittime]"/>
                            <!--<span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endDhSubmittime]"/>-->
                        </li>
                        <li>
                            <p>状态：</p>
                            <select name="purStatus">
                                <option value="">所有</option>
                                <option value="未提交">未提交</option>
                                <option value="已提交">已提交</option>
                                <option value="入库完成">入库完成</option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" href="javascript:create()"  shiro:hasPermission="essentials:purchase:add">
                <i class="fa fa-plus"></i> 创建新订单
            </a>

            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="essentials:purchase:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var removeFlag = [[${@permission.hasPermi('essentials:purchase:remove')}]];
    var details = [[${@permission.hasPermi('essentials:details:view')}]];
    var prefix = ctx + "essentials/purchase";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            modalName: "进货订单",
            columns: [{
                checkbox: true
            },
                {
                    field: 'purId',
                    title: '订单id',
                    visible: true
                },
                {
                    field: 'purStoId',
                    title: '入库单编号'
                },
                {
                    field: 'purMoney',
                    title: '总金额'
                },
                {
                    field: 'purSubmittime',
                    title: '时间'
                },
                {
                    field: 'purStatus',
                    title: '状态'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-primary btn-rounded btn-sm ' + details + '" href="/essentials/details?id=' + row.purId + '"><i class="fa fa-search"></i>查看详情</a>');
                            return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function create(){
        $.ajax({
            type:"post",
            url:"/essentials/purchase/addPurchase",
            success:function(data){
                $.modal.msg("创建成功！", modal_status.SUCCESS);
                $.table.search();
        },
            error:function (data) {
                $.modal.msg("操作失败！",modal_status.FAIL);
            }

    })
    }

</script>
</body>
</html>